package com.water.camera.mark;

import android.content.Context;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import com.water.camera.bean.EditItem;
import com.water.camera.databinding.LayoutWatermark89Binding;

import java.text.SimpleDateFormat;
import java.util.ArrayList;

public class Mark89 extends BaseMark {

    LayoutWatermark89Binding binding;

    public Mark89(@NonNull Context context) {
        super(context);
    }

    public Mark89(@NonNull Context context, @Nullable AttributeSet attrs) {
        super(context, attrs);
    }

    public Mark89(@NonNull Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
    }

    @Override
    protected void init(int type) {
        if (type == 0) {
            binding = LayoutWatermark89Binding.inflate(LayoutInflater.from(getContext()));
            addView(binding.getRoot());
            hideView(binding.binding20);
            for (int i = 3; i < binding.binding1.getChildCount(); i++) {
                binding.binding1.getChildAt(i).setVisibility(View.GONE);
            }
        } else {
            binding = LayoutWatermark89Binding.inflate(LayoutInflater.from(getContext()), this, true);
        }
        update();
    }

    @Override
    public void update() {
        setText(binding.title, "title89", binding.title);
        setText(binding.time, "time89", binding.time);
        setTime(binding.time, new SimpleDateFormat("yyyy.MM.dd"));

        setText(binding.binding3, "area89", binding.binding2);
        setText(binding.binding5, "content89", binding.binding4);
        setText(binding.binding7, "shigong89", binding.binding6);
        setText(binding.binding9, "jianli89", binding.binding8);
        setText(binding.binding11, "weather89", "晴", binding.binding10);
        setText(binding.binding13, "didian89", "在这里", binding.binding12);
        setText(binding.binding15, "haiba89", binding.binding14);
        setText(binding.binding17, "jingwei89", binding.binding16);
        setText(binding.binding19, "beizhu89", binding.binding18);
        setText(binding.binding22, "jianshedanwei89", binding.binding21);
        setText(binding.binding24, "jianlidanwei89", binding.binding23);
        setText(binding.binding26, "shigongdanwei89", binding.binding25);
        setText(binding.binding28, "shejidanwei89", binding.binding27);
        setText(binding.binding30, "kanchadanwei89", binding.binding29);

        super.update();
    }

    @Override
    public ArrayList<EditItem> getEditItems() {
        ArrayList<EditItem> list = new ArrayList<>();
        list.add(new EditItem("title89", "项目名称"));
        list.add(new EditItem("time89", "时间", true));
        list.add(new EditItem("area89", "施工区域"));
        list.add(new EditItem("content89", "施工内容"));
        list.add(new EditItem("shigong89", "施工责任人"));
        list.add(new EditItem("jianli89", "监理责任人"));
        list.add(new EditItem("weather89", "天气"));
        list.add(new EditItem("didian89", "地点"));
        list.add(new EditItem("haiba89", "海拔"));
        list.add(new EditItem("jingwei89", "经纬度"));
        list.add(new EditItem("beizhu89", "备注"));
        list.add(new EditItem("jianshedanwei89", "建设单位"));
        list.add(new EditItem("jianlidanwei89", "监理单位"));
        list.add(new EditItem("shigongdanwei89", "施工单位"));
        list.add(new EditItem("shejidanwei89", "设计单位"));
        list.add(new EditItem("kanchadanwei89", "勘察单位"));
        return list;
    }

    @Override
    public void onValueChange(EditItem item) {
        if (item.isTime) {
            setTime(binding.binding3, new SimpleDateFormat("yyyy.MM.dd"));
        } else {
            super.onValueChange(item);
        }
    }
}
